<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>单例模式弹框</title>
</head>
<style>
</style>
<body>
</body>
<script>
    function deepClone(obj){
        if(obj instanceof Map){
            let copy = new Map()

            return new Map(obj)
        }
        if(obj instanceof Set){
            return new Map(obj)
        }
        if(typeof obj !=="object" || obj == null){
            return obj 
        }
        if(obj instanceof Date || obj instanceof RegExp){
            return systemFunc(obj)
        }
        let copy = {}
        if(Array.isArray(obj)){
            copy = []
        }
        for(let key in obj){
            if(obj.hasOwnProperty(key)){
                copy[key] = deepClone(obj[key])
            }
        }

        return copy
    }
    function systemFunc(target){
        return new target.__proto__.constructor(target)
    }

    var x = {
        a:2,
        b:{
            c:2,
            d: new Date('2022-10-21'),
            e:new RegExp(/abc/g),
            f(){}
        },
        g : new Map([['Michael', 95], ['Bob', 75], ['Tracy', 85]]),
        h : new Set([1,2,3,3,2,1,5])
    }
    var x1 = deepClone(x)
    console.log(x,x1)
</script>
</html>